﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Clinica_Frba.UserInterface.Login
{
    public partial class LoginAs : Form
    {
        private MenuPrincipal menuAnterior;
        private string nombreUsuario;
        private string string_connection;

        public LoginAs(List<string> roles,MenuPrincipal anterior,string username,string conexion)
        {
            Console.WriteLine("Iniciando LoginAs");
            InitializeComponent();
            this.string_connection = conexion;
            this.menuAnterior = anterior;
            this.nombreUsuario = username;
            this.loginAs_accept.Enabled = false;
            foreach (string rol in roles)
            {
                roles_combo.Items.Add(rol);
            }
            
        }

        private void LoginAs_Load(object sender, EventArgs e)
        {
            Console.WriteLine("Loading LoginAs");
        }

        private void cancelarYvolver(object sender, EventArgs e)
        {
            this.menuAnterior.Show();
            this.Close();
        }

        public void volverApantallaPpal()
        {
            this.Close();
            this.menuAnterior.Show();
        }

        private void loginAs_accept_Click(object sender, EventArgs e)
        {
            string item = roles_combo.GetItemText(roles_combo.SelectedItem);
            MenuPrincipal menPpal = new MenuPrincipal(item, this.nombreUsuario, this.menuAnterior,this.string_connection);
            this.Close();
            menPpal.Show();
        }

        private void seleccionRol_event(object sender, EventArgs e)
        {
            string item = roles_combo.GetItemText(roles_combo.SelectedItem);
            if (item != "")
                this.loginAs_accept.Enabled = true;
            else
                this.loginAs_accept.Enabled = false;
        }

        public void salir()
        {
            this.Close();
            this.menuAnterior.salir();
        }
        
    }
}
